<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>供应商管理</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/css/base/base.css?20201106.1"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/laydate/skins/default/laydate.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>

    <style>
        * {font-family: "Microsoft Yahei" !important;}
        .header{
            margin-top: 15px;
            height: 40px;
        }
        .header .title{
            margin-left: 22px;
        }
        .header span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .content_label{
            line-height: 28px;
            font-size: 15px;
            color: rgb(111, 111, 111);
        }
        .content_label ul li{
            height: 16px;
            line-height: 16px;
            padding: 5px 12px;
            margin: 25px 0px;
            font-size: 15px;
            border-radius: 3px;
            display: inline;
        }
        .content_label ul{
            margin: 15px 0;
        }

        .pagediv table thead {
            background: white;
            line-height: 40px;
            border-bottom: 1px #dddddd solid;
            font-size: 13pt;
            color: #2F5C8F;
            font-weight: bold;
            height: 50px;
            border: 0px;
        }
        .pagediv tr:hover {
            background-color: #D3E7FA;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .pagediv tr:nth-child(odd) {
            background-color: #F6F7F9;
        }
        .queries{
            padding: 10px 20px;
            height: 40px;
        }
        #pageTbody tr{
            height: 40px;
        }
        .editAndDelete2{
            color: red;
        }
        .editAndDelete0{
            color: #2b7fe0;
        }
        .editAndDelete1{
            color: 2b7fe0;
        }
        #pop-up{
            height: 100%;
            position: fixed;
            top: -2px;
            right: -600px;
            display: none;
        }
        #keyWords{
            width: 130px;
            height: 30px;
            padding-left: 5px
        }
        .index_content_1 .one{
            color: white;
            padding: 4px;
        }
        .index_content_2 .one{
            color: white;
            padding: 4px;
        }

        #supplierImport{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            background-image: url(../../img/import/import.png);
            margin-top: -4px ;
        }
        #supplierExport{
            background-image: url(../../img/import/export.png);
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 4px;
            padding-left: 35px;
            margin-top: -4px ;
        }
        .one{
            width: 120px;
            height: 30px;
            border: none;
            color: #fff;
            cursor: pointer;
            padding: 5px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="header">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">供应商管理</span>
        <hr style="background-color: black"/>
    </div>
</div>

<div class="queries">
    <label>
        <input  placeholder="请输入供应商名称" type="text" id="keyWords" style="border-radius: 3px;margin-bottom: 2px;"/>
        <button  type="button" class="one" id="query_btn" style="width: 120px">
            <img src="../../img/workflow/worksearch1.png" style="margin-right: 8px;margin-bottom: 2px;"/>查询
        </button>
        <input  type="button" class="inquire_btn" value="导出" id="supplierExport" onclick="clicked1();"/>
        <input  type="button" class="inquire_btn" value="导入" id="supplierImport" onclick="clicked2();"/>
        <button  type="button" class="one" id="add_btn" style="width: 120px;" onclick="javascript:window.location.href='/supplier/saveSupplier';">
            <img src="../../img/mywork/newbuildworjk1.png" style="margin-right: 8px;margin-bottom: 2px;"/>新建
        </button>

    </label>
</div>
<div id="pagediv">

</div>

<div id="pop-up">
    <iframe id="childFrame" style="width: 520px;height: 100%"></iframe>
</div>
</body>
<script>
    $(function () {

        var screenwidth = document.documentElement.clientWidth;
        // console.log(screenwidth*0.9)
        if (screenwidth  > 1600) {
            var nums = screenwidth * 0.97;
            var sumwidth = screenwidth * 0.97 + 'px';
        } else {
            var nums = 800;
            var sumwidth = '1250px';
        }
        var width0 = nums * 0.055 + 'px';
        var width1 = nums * 0.055 + 'px';
        var width2 = nums * 0.075 + 'px';
        var width3 = nums * 0.105 + 'px';
        var width4 = nums * 0.105 + 'px';
        var width5 = nums * 0.075 + 'px';
        var width6 = nums * 0.065 + 'px';
        //表格初始化
        pageObj=$.tablePage('#pagediv',sumwidth,[
            {
                width:width0,
                title:'供应商名称',
                name:'supplierName',
                selectFun:function (n,obj) {
                    if(obj.supplierName==undefined){
                        return " "
                    }else{
                        return obj.supplierName;
                    }
                }
            },
            {
                width:width1,
                title:'供应商电话',
                name:'phone',
                selectFun:function (n,obj) {
                    if(obj.phone==undefined){
                        return " "
                    }else{
                        return obj.phone;
                    }
                }
            },
            {
                width:width2,
                title:'供应商网址',
                name:'website',
                selectFun:function (n,obj) {
                    if(obj.website==undefined){
                        return " "
                    }else{
                        return obj.website;
                    }
                }
            },
            {
                width:width3,
                title:'电子邮箱',
                name:'email',
                selectFun:function (n,obj) {
                    if(obj.email==undefined){
                        return " "
                    }else{
                        return obj.email;
                    }
                }
            },
            {
                width:width4,
                title:'供应商地址',
                name:'address',
                selectFun:function (n,obj) {
                    if(obj.address==undefined){
                        return " "
                    }else{
                        return obj.address;
                    }
                }
            },
            {
                width:width5,
                title:'创建时间',
                name:'createTime',
                selectFun:function (n,obj) {
                    if(obj.createTime==undefined){
                        return " "
                    }else{
                        return obj.createTime;
                    }
                }
            },
            {
                width:width6,
                title:'操作',
                name:'orgAddress'
            }
        ],function (me) {
            //            me.obj.codeId=$('[name="type"]').val();
            me.data.pageSize = 10;
            //1显示  // 2不显示  //不写fn这个属性就是全显示
            me.init("/supplier/selectByCount", [
                {name:'详情'},
                {name: '编辑'},
                {name: '删除'},
            ], function () {
                $('#query_btn').click(function () {
                    var keyWords = $('#keyWords').val();
                    me.data.supplierName = keyWords;
                    me.data.page = 1;
                    me.init("/supplier/selectByCount");

                })
            })
        })
        //根据id查询详情
        $('#pageTbody').on('click','.editAndDelete0',function() {
            var supplierId = pageObj.arrs[$(this).attr('data-i')].supplierId;
            window.location.href = '/supplier/detailSupplier?supplierId=' + supplierId;
        })

        //根据id修改
        //根据id编辑数据
        $('#pageTbody').on('click','.editAndDelete1',function() {
            var supplierId = pageObj.arrs[$(this).attr('data-i')].supplierId;
            window.location.href = '/supplier/updateSupplier?supplierId=' + supplierId;
        })
        //ajax 根据orgId 删除数据
        $('#pageTbody').on('click','.editAndDelete2',function(){
            var supplierId=pageObj.arrs[$(this).attr('data-i')].supplierId;
            layer.confirm(qued,{
                btn: [sure,cancel], //按钮
                title:'确定删除？'
            }, function(){
                $.ajax({
                    type:'post',
                    url:'/supplier/deleteByPrimaryKey',
                    dataType:'json',
                    data:{'supplierId':supplierId},
                    success:function(json){
                        if(json.flag==true){
                            layer.msg("删除成功",{
                                icon: 1,
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                window.location.href="/supplier/showSupplier"
                            })
                        }else {
                            layer.msg("删除失败",{
                                icon: 2,
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            },function(){
                                location.href="/supplier/showSupplier"
                            })
                        }
                    }
                })
            });
        });
    });
    //导入Excel
    function clicked2() {
        window.location.href = "/supplier/supplierImport"
    }
    //   导出Excel
    function clicked1() {
        window.location.href = "/supplier/supplierExport"
    }

</script>

</html>
